home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / bbs / mhis020.zip / CALLUTIL.MH < prev    next >
Text File  |  1996-09-17  |  2KB  |  97 lines

  1. #ifndef __CALLUTIL_MH
  2. #define __CALLUTIL_MH
  3.  
  4. #ifndef __DATE_MH
  5. #include "date.mh"
  6. #endif
  7.  
  8. long first_caller_index () {
  9.   int: temp;
  10.  
  11.   if (callers.forward_search) {
  12.     return 0;
  13.     }
  14.   else {
  15.     temp := call_numrecs ();
  16.     if (temp = 0) {
  17.       if (call_open ()) {
  18.         temp := call_numrecs ();
  19.         call_close ();
  20.         }
  21.       else {
  22.         print (COL_LRED, "Error openning callers log\n");
  23.         };
  24.       };
  25.     return (temp - 1);
  26.     };
  27.   }
  28.  
  29. long caller_index (string: index_string) {
  30.   long: idx;
  31.  
  32.   if (index_string = "") {
  33.     return first_caller_index ();
  34.     };
  35.   if (index_string = "=") {
  36.     return callers.index;
  37.     };
  38.   idx := stridx (index_string, 1, '\\');
  39.   if (idx) {
  40.     struct _date: thedate;
  41.     long: calls;
  42.     int: call_opened;
  43.     struct _callinfo: ci;
  44.  
  45.     call_opened := False;
  46.     calls := call_numrecs();
  47.     if (calls = 0) {
  48.       if (call_open () = False) {
  49.         print ("Cannot open callers log!!!\n");
  50.         };
  51.       calls := call_numrecs ();
  52.       call_opened := True;
  53.       };
  54.     string_to_date (thedate, index_string);
  55.  
  56.     if (callers.forward_search) {
  57.       idx := 0;
  58.       while (idx < calls AND call_read (idx, ci) AND date_greater (thedate, ci.login.date)) {
  59.         idx := idx + 1;
  60.         };
  61.       }
  62.     else {
  63.       idx := calls - 1;
  64.       while (idx >= 0 AND call_read (idx, ci) AND date_greater (ci.login.date, thedate)) {
  65.         idx := idx - 1;
  66.         };
  67.       };
  68.     if (call_opened) {
  69.       call_close ();
  70.       };
  71.     return idx;
  72.     };
  73.   return strtol (index_string);
  74.   }
  75.  
  76. long caller_index_forward (string: idx_string) {
  77.   bool: old_forward_flag;
  78.   long: result;
  79.  
  80.   old_forward_flag := callers.forward_search;
  81.   callers.forward_search := True;
  82.   result := caller_index (idx_string);
  83.   callers.forward_search := old_forward_flag;
  84.   }
  85.  
  86. long caller_index_backward (string: idx_string) {
  87.   bool: old_forward_flag;
  88.   long: result;
  89.  
  90.   old_forward_flag := callers.forward_search;
  91.   callers.forward_search := False;
  92.   result := caller_index (idx_string);
  93.   callers.forward_search := old_forward_flag;
  94.   }
  95.  
  96. #endif
  97.